package com.doctor.windflower_doctor.polling;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.doctor.windflower_doctor.fragment.MyQuestionHallFragment;

/**
 * Polling service
 * 
 * @Author
 * @Create
 */
public class PollingService extends Service {

	public static final String ACTION = "com.ryantang.service.PollingService";

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {
	}

	@Override
	public void onStart(Intent intent, int startId) {
		if (intent != null) {
			new PollingThread().start();
		}
	}

	private void showNotification() {
		if(MyQuestionHallFragment.isTance!=null)
		MyQuestionHallFragment.isTance.getNum(MyQuestionHallFragment.id);
	}

	/**
	 * Polling thread
	 * 
	 * @Author Ryan
	 * @Create 2013-7-13 10:18:34
	 */
	int count = 0;

	class PollingThread extends Thread {
		@Override
		public void run() {
			count++;
			if (count % 5 == 0) {
				showNotification();
			}
		}
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

}
